var pageii = null;
var grid = null;
$(function() {
	grid = lyGrid({
		pagId : 'paging',
		l_column : [ {
			colkey : "id",
			name : "id"
		},{
			colkey : "Date",
			name : "日期",
			renderData : function(rowindex,data, rowdata, column) {
				return new Date(data).format("yyyy-MM-dd hh:mm:ss");
		}
		},{
			colkey : "Classban",
			name : "班别"
		},{
			colkey : "FullName",
			name : "姓名"
		}, {
			colkey : "Post",
			name : "职务"
		}, {
			colkey : "Team_Machine",
			name : "班组机台"
		}, {
			colkey : "Mold_installation",
			name : "装模"
		}, {
			colkey : "Unqualified",
			name : "不合格"
		}, {
			colkey : "Passrate",
			name : "合格率"
		}, {
			colkey : "Standard_Time",
			name : "标准时间"
		}, {
			colkey : "When_Moused",
			name : "待装模用时"
		},{
			colkey : "Actual_Motime",
			name : "实际装模用时"
		},{
			colkey : "Average_Time",
			name : "平均用时"
		},{
			colkey : "Standard_Difference",
			name : "与标准差异"
		},{
			colkey : "Status",
			name : "状态"
		},{
			colkey : "",
			name : "操作"
		},],
		jsonUrl : rootPath + '/moreplacement/statistics_findByPage.shtml',
		dymCol:true,
		checkbox : true,
		serNumber : false
	});
	$("#addFun").click("click", function() {
		addAccount();
	});
	$("#editFun").click("click", function() {
		editAccount();
	});

	$("#delFun").click("click", function() {
		delAccount();
	});

	$("#search").click("click", function() {// 绑定查询按扭
		var searchParams = $("#searchForm").serializeJson();
		grid.setOptions({
			data : searchParams
		});
	});
	
});

function addAccount() {
	pageii = layer.open({
		title : "新增订单",
		type : 2,
		area : [ "800px", "100%" ],
		content : rootPath + '/moreplacement/statistics_add.shtml'
	});
}
function delAccount() {
var cbox = grid.getSelectedCheckbox();
if (cbox == "") {
	layer.msg("请选择删除项！！");
	return;
}
layer.confirm('是否删除？', function(index) {
	var url = rootPath + '/moreplacement/statistics_deleteEntity.shtml';
	var s = CommnUtil.ajax(url, {
		ids : cbox.join(",")
	}, "json");
	if (s == "success") {
		layer.msg('删除成功');
		grid.loadData();
		
	} else {
		layer.msg('删除失败');
	}
});

}
function editAccount() {
var cbox = grid.getSelectedCheckbox();
if (cbox.length > 1 || cbox == "") {
	layer.msg("只能选中一个");
	return;
}
pageii = layer.open({
	title : "编辑订单",
	type : 2,
	area : [ "800px", "100%" ],
	content : rootPath + '/moreplacement/statistics_edit.shtml?id=' + cbox
});
}